/**
* 版权所有：福建邮科电信业务部厦门研发中心 
*====================================================
* 文件名称: BeanFieldHandleFacade.java
* 修订记录：
* No    日期				作者(操作:具体内容)
* 1.    2013-3-29			詹保山(创建:创建文件)
*====================================================
* 类描述：(说明未实现或其它不应生成javadoc的内容)
* 
*/
package com.devframe.gc.handle;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.devframe.gc.meta.FieldMeta;
import com.devframe.gc.meta.IdFieldMeta;
import com.devframe.gc.meta.ZBSGCBeanInfoMeta;

public class BeanFieldHandleFacade {
	static BeanFieldHandler inputFieldHandle;
	static{
		inputFieldHandle=new InputFieldHandler();
		TextareaFieldHandler textareaHandle=new TextareaFieldHandler();
		IdFieldHandler idHandle=new IdFieldHandler();
		inputFieldHandle.buildNextHandle( textareaHandle);
		textareaHandle.buildNextHandle(idHandle);
		
	}
	
	private static  void toList(Field[] fields,@SuppressWarnings("rawtypes") ZBSGCBeanInfoMeta beanMeta,Map<String,Object> grobalParams){
		
		
		for(Field item:fields){
			FieldMeta meta=inputFieldHandle.process(item);
			meta.setGrobalParams(grobalParams);
			if(meta instanceof IdFieldMeta){
				beanMeta.setIdField((IdFieldMeta)meta);
			}else{
				beanMeta.addBeanField(meta);
			}
			
			
		}
	}
	public static ZBSGCBeanInfoMeta parseClazzFields(Class clazz,Map<String,Object> grobalParams){
		List<FieldMeta> beanFieldList=new ArrayList<FieldMeta>();
		ZBSGCBeanInfoMeta beanMeta=new ZBSGCBeanInfoMeta(clazz);
		beanFieldList=new ArrayList<FieldMeta>();
		beanMeta.setBeanFieldList(beanFieldList);
		
		toList(clazz.getDeclaredFields(),beanMeta,grobalParams);
		Class superClazz=clazz.getSuperclass();
		while(superClazz!=Object.class){
			superClazz.getDeclaredFields();
			toList(superClazz.getDeclaredFields(),beanMeta,grobalParams);
			superClazz=superClazz.getSuperclass();
		}
		//进行排序操作
		
		return beanMeta;
	}
	
	
	
}
